/*
 * @Date: 2024-12-06 10:59:21
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2024-12-06 11:18:57
 * @Description: 
 */
import { reactive } from 'vue';
import { storeToRefs } from 'pinia';
import { useTagsViewRoutes } from '@/stores/tagsViewRoutes';

const toolState = reactive({
  toolRoutes: []
})

export const useToolRoute = (params) => {

  const { tagsViewRoutes } = storeToRefs(useTagsViewRoutes());

  const getToolRoutes = () => {
    if (toolState.toolRoutes.length > 0) {
      return toolState.toolRoutes;
    } else {
      for (let v of tagsViewRoutes.value) {
        if (v.meta?.isHide) continue;
        if (v.children && v.children.length > 0) continue;
        toolState.toolRoutes.push({
          label: v.meta.title, value: v.path
        });
      }
      console.log('toolState.toolRoutes', toolState.toolRoutes);
      return toolState.toolRoutes;
    }
  }


  return {
    getToolRoutes
  }
}